import hardware

sc = hardware.Screen()
mmu = hardware.MMU()
mmu.loadRom("Roms/TETRIS.gb")
mmu.romInit()
cpu = hardware.CPU()
cpu.executeNextOpcode(mmu)
cpu.executeNextOpcode(mmu)
cpu.executeNextOpcode(mmu)
cpu.executeNextOpcode(mmu)
cpu.executeNextOpcode(mmu)
cpu.executeNextOpcode(mmu)
cpu.executeNextOpcode(mmu)


def run(screen, cpu, rom):
    maxCycles = 69905
    while True:
        cycles = 0
        cyclesThisUpdate = 0
        while cyclesThisUpdate < maxCycles:
            cpu.executeNextOpcode(mmu)
            cycles += 3
            cyclesThisUpdate += cycles
            # cpu.updateTimers()
            # cpu.updateGraphics()
            # cpu.handleInterrupts()
            
        #renderScreen()
       # print "Render Screen"
    
    
run(sc, cpu, mmu)
        



